home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / TranslationExtensions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  6.6 KB  |  208 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        TranslationExtensions.h
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1989-1997, 1995, 1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __TRANSLATIONEXTENSIONS__
  19. #define __TRANSLATIONEXTENSIONS__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27. #ifndef __QUICKDRAW__
  28. #include <Quickdraw.h>
  29. #endif
  30. #ifndef __COMPONENTS__
  31. #include <Components.h>
  32. #endif
  33.  
  34.  
  35.  
  36. #if PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_STRUCT_ALIGN
  49.     #pragma options align=mac68k
  50. #elif PRAGMA_STRUCT_PACKPUSH
  51.     #pragma pack(push, 2)
  52. #elif PRAGMA_STRUCT_PACK
  53.     #pragma pack(2)
  54. #endif
  55.  
  56.  
  57. enum {
  58.     kSupportsFileTranslation    = 1,
  59.     kSupportsScrapTranslation    = 2,
  60.     kTranslatorCanGenerateFilename = 4
  61. };
  62.  
  63.  
  64. /* better names for 4-char codes*/
  65. typedef OSType                             FileType;
  66. typedef ResType                         ScrapType;
  67. typedef unsigned long                     TranslationAttributes;
  68.  
  69. enum {
  70.     taDstDocNeedsResourceFork    = 1,
  71.     taDstIsAppTranslation        = 2
  72. };
  73.  
  74.  
  75. struct FileTypeSpec {
  76.     FileType                         format;
  77.     long                             hint;
  78.     TranslationAttributes             flags;                        /* taDstDocNeedsResourceFork, taDstIsAppTranslation*/
  79.     OSType                             catInfoType;
  80.     OSType                             catInfoCreator;
  81. };
  82. typedef struct FileTypeSpec FileTypeSpec;
  83.  
  84. struct FileTranslationList {
  85.     unsigned long                     modDate;
  86.     unsigned long                     groupCount;
  87.                                                                 /*     unsigned long    group1SrcCount;*/
  88.                                                                 /*     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);*/
  89.                                                                 /*  FileTypeSpec    group1SrcTypes[group1SrcCount]*/
  90.                                                                 /*  unsigned long    group1DstCount;*/
  91.                                                                 /*  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);*/
  92.                                                                 /*  FileTypeSpec    group1DstTypes[group1DstCount]*/
  93. };
  94. typedef struct FileTranslationList FileTranslationList;
  95.  
  96. typedef FileTranslationList *            FileTranslationListPtr;
  97. typedef FileTranslationListPtr *        FileTranslationListHandle;
  98.  
  99. struct ScrapTypeSpec {
  100.     ScrapType                         format;
  101.     long                             hint;
  102. };
  103. typedef struct ScrapTypeSpec ScrapTypeSpec;
  104.  
  105. struct ScrapTranslationList {
  106.     unsigned long                     modDate;
  107.     unsigned long                     groupCount;
  108.                                                                 /*     unsigned long        group1SrcCount;*/
  109.                                                                 /*     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);*/
  110.                                                                 /*  ScrapTypeSpec        group1SrcTypes[group1SrcCount]*/
  111.                                                                 /*  unsigned long        group1DstCount;*/
  112.                                                                 /*     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);*/
  113.                                                                 /*  ScrapTypeSpec        group1DstTypes[group1DstCount]*/
  114. };
  115. typedef struct ScrapTranslationList ScrapTranslationList;
  116.  
  117. typedef ScrapTranslationList *            ScrapTranslationListPtr;
  118. typedef ScrapTranslationListPtr *        ScrapTranslationListHandle;
  119. /* definition of callbacks to update progress dialog*/
  120. typedef long                             TranslationRefNum;
  121. /*****************************************************************************************
  122. *
  123. * This routine sets the advertisement in the top half of the progress dialog.
  124. * It is called once at the beginning of your DoTranslateFile routine.
  125. *
  126. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  127. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  128. *                            Before returning from DoTranslateFile, you should dispose
  129. *                            of the memory.  (Normally, it is in the temp translation heap
  130. *                            so it is cleaned up for you.)
  131. *
  132. * Exit:    returns            noErr, paramErr, or memFullErr
  133. */
  134. EXTERN_API( OSErr )
  135. SetTranslationAdvertisement        (TranslationRefNum         refNum,
  136.                                  PicHandle                 advertisement)                        TWOWORDINLINE(0x7002, 0xABFC);
  137.  
  138.  
  139. /*****************************************************************************************
  140. *
  141. * This routine updates the progress bar in the progress dialog.
  142. * It is called repeatedly from within your DoTranslateFile routine.
  143. * It should be called often, so that the user will get feedback if he tries to cancel.
  144. *
  145. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  146. *            progress    percent complete (0-100)
  147. *
  148. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  149. *            returns        noErr, paramErr, or memFullErr
  150. */
  151. EXTERN_API( OSErr )
  152. UpdateTranslationProgress        (TranslationRefNum         refNum,
  153.                                  short                     percentDone,
  154.                                  Boolean *                canceled)                            TWOWORDINLINE(0x7001, 0xABFC);
  155.  
  156.  
  157.  
  158. /* ComponentMgr selectors for routines*/
  159.  
  160. enum {
  161.     kTranslateGetFileTranslationList = 0,                        /* component selectors*/
  162.     kTranslateIdentifyFile        = 1,
  163.     kTranslateTranslateFile        = 2,
  164.     kTranslateGetTranslatedFilename = 3,
  165.     kTranslateGetScrapTranslationList = 10,                        /* skip to scrap routines*/
  166.     kTranslateIdentifyScrap        = 11,
  167.     kTranslateTranslateScrap    = 12
  168. };
  169.  
  170.  
  171. /* Routines to implment in a file translation extension*/
  172.  
  173.  
  174. typedef CALLBACK_API( ComponentResult , DoGetFileTranslationListProcPtr )(ComponentInstance self, FileTranslationListHandle translationList);
  175. typedef CALLBACK_API( ComponentResult , DoIdentifyFileProcPtr )(ComponentInstance self, const FSSpec *theDocument, FileType *docType);
  176. typedef CALLBACK_API( ComponentResult , DoTranslateFileProcPtr )(ComponentInstance self, TranslationRefNum refNum, const FSSpec *sourceDocument, FileType srcType, long srcTypeHint, const FSSpec *dstDoc, FileType dstType, long dstTypeHint);
  177. typedef CALLBACK_API( ComponentResult , DoGetTranslatedFilenameProcPtr )(ComponentInstance self, FileType dstType, long dstTypeHint, FSSpec *theDocument);
  178.  
  179. /* Routine to implement in a scrap translation extension*/
  180.  
  181. typedef CALLBACK_API( ComponentResult , DoGetScrapTranslationListProcPtr )(ComponentInstance self, ScrapTranslationListHandle list);
  182. typedef CALLBACK_API( ComponentResult , DoIdentifyScrapProcPtr )(ComponentInstance self, const void *dataPtr, Size dataLength, ScrapType *dataFormat);
  183. typedef CALLBACK_API( ComponentResult , DoTranslateScrapProcPtr )(ComponentInstance self, TranslationRefNum refNum, const void *srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint, Handle dstData, ScrapType dstType, long dstTypeHint);
  184.  
  185.  
  186.  
  187.  
  188. #if PRAGMA_STRUCT_ALIGN
  189.     #pragma options align=reset
  190. #elif PRAGMA_STRUCT_PACKPUSH
  191.     #pragma pack(pop)
  192. #elif PRAGMA_STRUCT_PACK
  193.     #pragma pack()
  194. #endif
  195.  
  196. #ifdef PRAGMA_IMPORT_OFF
  197. #pragma import off
  198. #elif PRAGMA_IMPORT
  199. #pragma import reset
  200. #endif
  201.  
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205.  
  206. #endif /* __TRANSLATIONEXTENSIONS__ */
  207.  
  208.